

#pragma once

#include <signal.h>

namespace tools
{
    void ReactionForCrash(int signalnum)
    {
        puts("Crash_intercept!\n");
        //gCore.Flush();
        signal(signalnum, SIG_DFL);  
        exit(3); 
    }
    void fnExit(void) {  puts("Procedure of terminate process\n"); }

    void InterceptCrashState()
    {
        atexit(fnExit); 

        signal(SIGABRT, ReactionForCrash); 
        signal(SIGSEGV, ReactionForCrash);
        signal(SIGILL,  ReactionForCrash);
        signal(SIGFPE,  ReactionForCrash);

        #ifndef _MSC_VER
        signal(SIGBUS,  ReactionForCrash); 
        #endif
    }


}// namespace tools
